<template>
  <div class="window">
    <div class="header">
      学习交流
    </div>
    <div class="list">
      <div
        class="detail"
        v-for="item in messages"
        :key="item.id"
      >
        <div class="time">{{(item.time)}}</div>
        <div :class="item.username === name ? 'msg-self' : 'msg'">
          <div class="head">
            <img
              class="headimg"
              :src="item.userimgUrl ? item.userimgUrl : 'http://user-images-1257142679.cos.ap-chengdu.myqcloud.com/1c6a8e065078710170d219893949ccae'"
            >
          </div>
          <div :class="item.username === name ? 'nickname-self' : 'nickname'">
            <div class="name">
              {{item.username}}
            </div>
            <div
              class="message"
              :class="item.username === name ? 'message-self' : ''"
            >
              {{item.message}}
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="footer">
      <el-input
        type="textarea"
        :rows="7"
        resize="none"
      >
      </el-input>
      <div class="send">
        <el-button
          type="primary"
          size="small"
        >
          发送
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DefaultDetail',
  data () {
    return {
      name: 'xx',
      messages: [
        {
          time: '2019年8月17日 0:57',
          username: '123',
          message: '消息内容'
        }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>
$header-width: 50px;
$border-color: #ccc;
$border: 1px solid $border-color;
.window {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  .header {
    flex: 0 0 50px;
    width: 100%;
    height: $header-width;
    line-height: $header-width;
    border-bottom: $border;
  }
  .list {
    width: 100%;
    flex: 1;
    overflow-y: scroll;
    .detail {
      margin-bottom: 5px;
    }

    .time {
      margin: 0 auto;
      text-align: center;
      width: 200px;
      background-color: #ccc;
      color: #eee;
      border-radius: 3px;
      font-size: 12px;
    }

    .msg {
      display: flex;
    }

    .msg-self {
      display: flex;
      flex-direction: row-reverse;
    }

    .head {
      flex: 0 0 80px;
      height: 80px;
    }

    .headimg {
      margin: 10px;
      width: 50px;
      height: 50px;
    }

    .nickname {
      box-sizing: border-box;
      flex: 0 0 70%;
      text-align: left;
    }

    .nickname-self {
      box-sizing: border-box;
      flex: 0 0 70%;
      text-align: right;
    }

    .name {
      margin: 8px 0 0 0;
      width: 100%;
      height: 20px;
      line-height: 20px;
      color: #666;
    }

    .message {
      box-sizing: border-box;
      padding: 5px;
      font-size: 16px;
      text-align: left;
      display: inline-block;
      background-color: #ccc;
      border-radius: 5px;
    }

    .message-self {
      background-color: #6c6;
    }

    .send {
      flex: 0 0 300px;
      width: 100%;
    }

    .content {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      width: 100%;
      height: 250px;
      font-size: 25px;
      border: none;
      border-top: 1px solid #ccc;
      padding: 10px;
    }

    .btn {
      text-align: right;
    }
  }
  .footer {
    flex: 0 0 200px;
    background-color: $white;
    width: 100%;
    .send {
      text-align: right;
      padding-right: 70px;
    }
  }
}
</style>
